package com.xiyoukt.springboot.controller;

import com.xiyoukt.springboot.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//@Controller+@ResponseBody
public class HelloWorldController {

    @Autowired
    private Person person;

    @Value("${person.name}")
    private String personName;

//    @Value("${person.math_grade}")
//    private String mathGrade;

    @Value("#{(1+1)*2}")
    private Integer result;

    @Value("#{systemProperties['java.version']}")
    private String javaVersion;

    @Value("${config}")
    private String config;

    @Autowired
    private Data data;

    @Value("${str}")
    private String str;

    @Value("${c:d}")
    private String c;

    @GetMapping("helloWorld")
    public String helloWorld(){
        System.out.println(person.getName());
        System.out.println(person.getAge());
        System.out.println(person.getMathGrade());
        System.out.println(person.getRandom());
        System.out.println("===");
        System.out.println(person.getList().get(0));
        System.out.println(person.getList().get(1));
        System.out.println(person.getMap().get("k1"));
        System.out.println(person.getMap().get("k2"));
        System.out.println("===");
        System.out.println(personName);
//        System.out.println(mathGrade);
        System.out.println("===");
        System.out.println(result);
        System.out.println(javaVersion);
        System.out.println("===");
        System.out.println(config);
        System.out.println("===");
        System.out.println(data.getNum());
        System.out.println(data.getType());
        System.out.println("===");
        System.out.println(str);

        return "hello world";
    }

    @Autowired
    private ConfigEntity configEntity;

    @Autowired
    private Animal animal;

    @Autowired
    private ConfigEntity2 configEntity2;

    @Autowired
    private XMLData xmlData;

    @GetMapping("test")
    public String test(){
        System.out.println(configEntity.getConfigName());
        System.out.println(configEntity.getConfigValue());
        System.out.println(configEntity.getOtherConfigEntity().getConfigInfo());
        animal.hat();
        System.out.println(configEntity2.getConfig());
        System.out.println(xmlData.getConfigName());
        System.out.println(xmlData.getConfigValue());
        return "test";
    }

}
